package conf
import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

// PgSection map toml [pg]
type PgSection struct {
	Host string
	Port string
	User string
	Password string
	Database string
}

// ReadPg get pg section from config
func ReadPg (v *viper.Viper, slog *zap.SugaredLogger) (pgConf PgSection) {
	err := v.Unmarshal(&pgConf)
	if err != nil {
		slog.Panicf("unable to decode into pg section, %v", err)
	}
	slog.Debug(pgConf)
	return
}